<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /* 子元素不设宽度width，会继承父元素的width */
        /* 子元素设绝对定位之后，不会再继承父元素的width */
        *{
            margin:0;
            padding:0;
        }
        .parent{
            width: 200px;
            height: 200px;
            background-color: red;
        }
        .child{
            height: 100px;
            background-color: rgb(142, 73, 221);
        }
    </style>
</head>
<body>
    <div class="parent">
        <div class="child"></div>
    </div>
</body>
</html>